var mock = require('mockjs');
var fs = require('fs');
var Random = mock.Random;
var mock = mock.mock;



var obj = {
    /**
     * 创建用户
     */
    madeUser() {
        var obj = mock({
            'userId': mock('@id'),
            'username': mock('@cname'),
            'age|18-45': 1,
            'gender|1': ['男', '女'],
            'addr': mock('@county(true)'),
        });
        return obj;
    },
    // 获取用户列表
    getUserList(num) {
        var list = [];
        for (var i = 0; i < num; i++) {
            var obj = this.madeUser();
            list.push(obj);
        }
        return list;
    },

    /**
    * 创建仓库
    */
    madeStore(count = 0) {
        var obj = mock({
            'userId|1': ["620000201209145320", "330000198911276300", "510000197104211083", "150000201301200510", "430000198604162470"],
            'username|1': ["史军", "雷丽", "潘刚", "魏娟", "刘超"],
            'addr': mock('@county(true)'),
            'storeId': mock('@id'),
            'addr':  mock('@string(20)') + '.git',
            'storeName':  mock('@city(false)').replace(/\s*/g,"") +' 仓库'
        });
        return obj;
    },
    // 获取仓库列表
    getStoreList(num) {
        var list = [];
        for (var i=0;i<num;i++) {
            var obj = this.madeStore();
            list.push(obj);
        }
   
        return list;
    }

}


// var list = obj.getUserList(5);
// fs.writeFileSync('user.json', JSON.stringify(list));

var list2 = obj.getStoreList(25);
fs.writeFileSync('storeList.json', JSON.stringify(list2));


